﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace Hive.Core.Model
{
    /// <summary>
    /// Provides administration functions for creating and opening hives.
    /// </summary>
    public interface IHiveManager
    {
        /// <summary>
        /// Finds the hive directory to which the current directory belongs.
        /// </summary>
        /// <param name="currentDirectory">The current directory.</param>
        /// <returns>The hive directory, or null if not found.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="currentDirectory"/> is null.</exception>
        DirectoryInfo FindHiveDirectory(DirectoryInfo currentDirectory);

        /// <summary>
        /// Returns true if the specified directory represents a hive.
        /// </summary>
        /// <param name="directory">The hive directory.</param>
        /// <returns>True if the directory exists and represents a hive.</returns>
        bool Exists(DirectoryInfo directory);

        /// <summary>
        /// Opens an existing hive at the specified directory.
        /// </summary>
        /// <param name="directory">The hive directory.</param>
        /// <returns>The existing hive.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="directory"/> is null.</exception>
        /// <exception cref="HiveException">Thrown if the requested hive does not exist or cannot be opened.</exception>
        IHive Open(DirectoryInfo directory);

        /// <summary>
        /// Creates a new hive at the specified directory.
        /// </summary>
        /// <param name="directory">The hive directory.</param>
        /// <param name="configuration">The configuration of the new hive.</param>
        /// <returns>The new hive.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="directory"/>
        /// or <paramref name="configuration"/> is null.</exception>
        /// <exception cref="HiveException">Thrown if the directory already exists or if the hive cannot be created.</exception>
        IHive Create(DirectoryInfo directory, HiveConfiguration configuration);

        /// <summary>
        /// Modifies the configuration of the hive.
        /// </summary>
        /// <param name="directory">The hive directory.</param>
        /// <param name="configuration">The configuration of the new hive.</param>
        /// <returns>The new hive.</returns>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="directory"/>
        /// or <paramref name="configuration"/> is null.</exception>
        /// <exception cref="HiveException">Thrown if the directory does not exist or cannot be opened.</exception>
        void Reconfigure(DirectoryInfo directory, HiveConfiguration configuration);
    }
}
